/**
 * 
 */
package net.sf.graph4j.element.graph;


import java.util.LinkedHashMap;
import java.util.Map;

import net.sf.graph4j.element.AbstractPropertied;
import net.sf.graph4j.element.tree.TreeNode;

/**
 * @author chen cong
 *
 */
public class Vertex extends AbstractPropertied{

	Map<Edge, Vertex> incomingEdgesToVertices = new LinkedHashMap<Edge, Vertex>();
	
	Map<Edge, Vertex> outgoingEdgesToVertices = new LinkedHashMap<Edge, Vertex>();
	
	Map<Edge, Vertex> connectingEdgesToVertices = new LinkedHashMap<Edge, Vertex>();

	public Vertex(TreeNode node) {
		this.putAllProperty(node.getProperties());
	}

	public Vertex() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @return Returns the connectingEdgesToVertices.
	 */
	public Map<Edge, Vertex> getConnectingEdgesToVertices() {
		return connectingEdgesToVertices;
	}

	/**
	 * @return Returns the incomingEdgesToVertices.
	 */
	public Map<Edge, Vertex> getIncomingEdgesToVertices() {
		return incomingEdgesToVertices;
	}

	/**
	 * @return Returns the outgoingEdgesToVertices.
	 */
	public Map<Edge, Vertex> getOutgoingEdgesToVertices() {
		return outgoingEdgesToVertices;
	}
	
	public void addIncomingEdge (Edge edge, Vertex vertex) {
		incomingEdgesToVertices.put(edge, vertex);
		connectingEdgesToVertices.put(edge, vertex);
	}
	
	public void addOutgoingEdge (Edge edge, Vertex vertex) {
		outgoingEdgesToVertices.put(edge, vertex);
		connectingEdgesToVertices.put(edge, vertex);
	}
	
	public void addConnectionEdge (Edge edge, Vertex vertex) {
		incomingEdgesToVertices.put(edge, vertex);
		outgoingEdgesToVertices.put(edge, vertex);
		connectingEdgesToVertices.put(edge, vertex);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "Vertex" + "("
			+ getProperties().toString() + ")";
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#clone()
	 */
	@Override
	public Vertex clone() throws CloneNotSupportedException {
		// TODO Auto-generated method stub
		Vertex v = new Vertex();
		v.putAllProperty(getProperties());
		return v;
	}
}
